home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Diamond Collection / The Diamond Collection (Software Vault)(Digital Impact).ISO / cdr45 / mdidmo.zip / MDIDRAW.FRM < prev    next >
Text File  |  1994-04-12  |  10KB  |  352 lines

  1. VERSION 2.00
  2. Begin MDIForm frmMain 
  3.    Caption         =   "MDI Background Demo"
  4.    ClientHeight    =   5190
  5.    ClientLeft      =   1095
  6.    ClientTop       =   1770
  7.    ClientWidth     =   9165
  8.    Height          =   5880
  9.    Left            =   1035
  10.    LinkTopic       =   "MDIForm1"
  11.    Top             =   1140
  12.    Width           =   9285
  13.    Begin SSPanel pStatus 
  14.       Align           =   2  'Align Bottom
  15.       BevelInner      =   1  'Inset
  16.       Caption         =   "pStatus"
  17.       Font3D          =   3  'Inset w/light shading
  18.       Height          =   405
  19.       Left            =   0
  20.       TabIndex        =   9
  21.       Top             =   4785
  22.       Width           =   9165
  23.    End
  24.    Begin SSPanel Panel3D1 
  25.       Align           =   1  'Align Top
  26.       Height          =   2025
  27.       Left            =   0
  28.       TabIndex        =   8
  29.       Top             =   0
  30.       Width           =   9165
  31.       Begin MsgBlaster MsgBlaster1 
  32.          Prop8           =   "Click on ""..."" for the About Box ---->"
  33.          Left            =   4770
  34.          Top             =   990
  35.       End
  36.       Begin PictureBox Picture2 
  37.          AutoRedraw      =   -1  'True
  38.          AutoSize        =   -1  'True
  39.          BorderStyle     =   0  'None
  40.          Height          =   2880
  41.          Left            =   1410
  42.          Picture         =   MDIDRAW.FRX:0000
  43.          ScaleHeight     =   2880
  44.          ScaleWidth      =   3075
  45.          TabIndex        =   11
  46.          Top             =   990
  47.          Visible         =   0   'False
  48.          Width           =   3075
  49.       End
  50.       Begin PictureBox Picture1 
  51.          AutoRedraw      =   -1  'True
  52.          AutoSize        =   -1  'True
  53.          BorderStyle     =   0  'None
  54.          Height          =   810
  55.          Left            =   270
  56.          Picture         =   MDIDRAW.FRX:4466
  57.          ScaleHeight     =   810
  58.          ScaleWidth      =   840
  59.          TabIndex        =   10
  60.          Top             =   990
  61.          Visible         =   0   'False
  62.          Width           =   840
  63.       End
  64.       Begin OptionButton FocusTrap 
  65.          BackColor       =   &H00C0C0C0&
  66.          Caption         =   "Option1"
  67.          Height          =   255
  68.          Left            =   8700
  69.          TabIndex        =   0
  70.          Top             =   150
  71.          Value           =   -1  'True
  72.          Width           =   225
  73.       End
  74.       Begin CommandButton cButton 
  75.          Caption         =   "Show All"
  76.          Height          =   345
  77.          Index           =   5
  78.          Left            =   6150
  79.          TabIndex        =   6
  80.          Tag             =   "Unhide all ""hidden"" child document forms"
  81.          Top             =   90
  82.          Width           =   1215
  83.       End
  84.       Begin CommandButton cButton 
  85.          Caption         =   "Vertical"
  86.          Height          =   345
  87.          Index           =   4
  88.          Left            =   4950
  89.          TabIndex        =   5
  90.          Tag             =   "Tile vertically all ""visible"" document child forms"
  91.          Top             =   90
  92.          Width           =   1215
  93.       End
  94.       Begin CommandButton cButton 
  95.          Caption         =   "Exit"
  96.          Height          =   345
  97.          Index           =   6
  98.          Left            =   7350
  99.          TabIndex        =   7
  100.          Tag             =   "Exit demonstration"
  101.          Top             =   90
  102.          Width           =   1215
  103.       End
  104.       Begin CommandButton cButton 
  105.          Caption         =   "Horizontal"
  106.          Height          =   345
  107.          Index           =   3
  108.          Left            =   3750
  109.          TabIndex        =   4
  110.          Tag             =   "Tile horizontally all ""visible"" document child forms"
  111.          Top             =   90
  112.          Width           =   1215
  113.       End
  114.       Begin CommandButton cButton 
  115.          Caption         =   "Cascade"
  116.          Height          =   345
  117.          Index           =   2
  118.          Left            =   2550
  119.          TabIndex        =   3
  120.          Tag             =   "Cascade all ""visible"" child document forms"
  121.          Top             =   90
  122.          Width           =   1215
  123.       End
  124.       Begin CommandButton cButton 
  125.          Caption         =   "New"
  126.          Height          =   345
  127.          Index           =   1
  128.          Left            =   1350
  129.          TabIndex        =   2
  130.          Tag             =   "Create new instance of document child form"
  131.          Top             =   90
  132.          Width           =   1215
  133.       End
  134.       Begin CommandButton cButton 
  135.          Caption         =   "Background"
  136.          Height          =   345
  137.          Index           =   0
  138.          Left            =   150
  139.          TabIndex        =   1
  140.          Tag             =   "Toggle between MDI backgrounds"
  141.          Top             =   90
  142.          Width           =   1215
  143.       End
  144.    End
  145.    Begin Menu mMain 
  146.       Caption         =   "&Parent Menu"
  147.       Begin Menu mTest 
  148.          Caption         =   "E&xit"
  149.       End
  150.    End
  151. End
  152. '---------------------------------------------------------------------------
  153. ' MDI Background Demo Program, Copyright (c) 1994 Karl E. Peterson
  154. ' Redistributed by permission.    CompuServe: 72302,3707
  155. ' See MDIDEMO.BAS for complete description
  156. '---------------------------------------------------------------------------
  157.  
  158. 'Default behavior
  159.   DefInt A-Z
  160.   Option Explicit
  161.  
  162. 'Index into toolbar buttons
  163.   Const bBackground = 0
  164.   Const bNew = 1
  165.   Const bCascade = 2
  166.   Const bHorz = 3
  167.   Const bVert = 4
  168.   Const bShow = 5
  169.   Const bExit = 6
  170.  
  171. 'Variable to track current background
  172.   Dim BackStyle%
  173.   Const HiBackStyle = 7
  174.  
  175. Sub cButton_Click (Index As Integer)
  176.   
  177.   FocusTrap.SetFocus
  178.   Select Case Index
  179.     Case bBackground
  180.       'Increment current background
  181.       BackStyle = BackStyle + 1
  182.       If BackStyle > HiBackStyle Then
  183.         BackStyle = 0
  184.       End If
  185.       MDIForm_Paint
  186.     
  187.     Case bNew
  188.       mdiNew
  189.  
  190.     Case bCascade
  191.       mdiArrange WM_MDICASCADE
  192.  
  193.     Case bHorz
  194.       mdiArrange MDITILE_HORIZONTAL
  195.  
  196.     Case bVert
  197.       mdiArrange MDITILE_VERTICAL
  198.  
  199.     Case bShow
  200.       mdiShowAll
  201.     
  202.     Case bExit
  203.       mdiShowAll
  204.       Unload Me
  205.  
  206.   End Select
  207.   
  208. End Sub
  209.  
  210. Sub cButton_MouseMove (Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
  211.   'Update status bar
  212.     DisplayStatus (cButton(Index).Tag)
  213. End Sub
  214.  
  215. Sub MDIForm_Load ()
  216.   
  217.   'Position form on screen, use 640x480 as target dims
  218.     Dim newWidth%, newHeight%
  219.     newWidth = 640 * Screen.TwipsPerPixelX
  220.     If Screen.Height > 480 * Screen.TwipsPerPixelY Then
  221.       newHeight = 480 * Screen.TwipsPerPixelY
  222.     Else
  223.       newHeight = .9 * Screen.Height
  224.     End If
  225.     Move (Screen.Width - newWidth) \ 2, (Screen.Height - newHeight) \ 2, newWidth, newHeight
  226.     
  227.   'Position/Resize toolbar panel
  228.     Panel3D1.Height = 2 * cButton(0).Top + cButton(0).Height
  229.     FocusTrap.Move FocusTrap.Width * -3
  230.  
  231.   'Set up child arrays
  232.     ReDim fDoc(1)    'array of child forms
  233.     ReDim fState(1)  'array to track child state
  234.  
  235.   'Create first child and clear status bar
  236.     mdiNew
  237.     DisplayStatus ""
  238.  
  239.   'Setup MsgBlast control
  240.     MsgBlaster1.hWndTarget = (GetWindow(Me.hWnd, GW_CHILD))
  241.     MsgBlaster1.MsgList(0) = WM_PAINT
  242.     MsgBlaster1.MsgPassage(0) = MB_PREPROCESS
  243.     MsgBlaster1.MsgList(1) = WM_ERASEBKGND
  244.     MsgBlaster1.MsgPassage(1) = MB_EATMESSAGE
  245.    
  246. End Sub
  247.  
  248. Sub MDIForm_Paint ()
  249.   
  250. 'Our substitute Paint event (since VB doesn't give us one)
  251.   Select Case BackStyle
  252.     Case 0
  253.       mdiPaintSolid (Me.hWnd), &H400000
  254.       mdiTextOut (Me.hWnd), " Solid Fill ", 10, 10
  255.  
  256.     Case 1
  257.       mdiBitBltTiled (Picture1.hWnd), (Picture1.hDC), (Me.hWnd)
  258.       mdiTextOut (Me.hWnd), " Tiled Pattern ", 10, 10
  259.  
  260.     Case 2
  261.       mdiPaintGradiant (Me.hWnd)
  262.       mdiTextOut (Me.hWnd), " Gradiant Fill, Style 1 ", 10, 10
  263.  
  264.     Case 3
  265.       DoEvents
  266.       mdiPaintTunnel1 (Me.hWnd)
  267.       mdiTextOut (Me.hWnd), " Gradiant Fill, Style 2 ", 10, 10
  268.  
  269.     Case 4
  270.       DoEvents
  271.       mdiPaintTunnel2 (Me.hWnd)
  272.       mdiTextOut (Me.hWnd), " Gradiant Fill, Style 3 ", 10, 10
  273.  
  274.     Case 5
  275.       mdiPaintSolid (Me.hWnd), 0&
  276.       mdiBitBltCentered (Picture2.hWnd), (Picture2.hDC), (Me.hWnd)
  277.       mdiTextOut (Me.hWnd), " Centered Bitmap ", 10, 10
  278.  
  279.     Case 6
  280.       mdiPaintSolid (Me.hWnd), 0&
  281.       mdiStretchBlt (Picture2.hWnd), (Picture2.hDC), (Me.hWnd), True
  282.       mdiTextOut (Me.hWnd), " Stretched (Proportionally) Bitmap ", 10, 10
  283.  
  284.     Case 7
  285.       mdiStretchBlt (Picture2.hWnd), (Picture2.hDC), (Me.hWnd), False
  286.       mdiTextOut (Me.hWnd), " Stretched (Non-Proportionally) Bitmap ", 10, 10
  287.  
  288.   End Select
  289.  
  290. End Sub
  291.  
  292. Sub MDIForm_Resize ()
  293.   
  294.   Static LastState%, LastWidth%, LastHeight%
  295.   If LastState = MAXIMIZED Then
  296.     'ensure a repaint (doesn't always happen)
  297.       MDIForm_Paint
  298.   End If
  299.   
  300.   If Me.WindowState <> MINIMIZED Then
  301.     'rearrange icons
  302.       'mdiArrange WM_MDIICONARRANGE
  303.   End If
  304.  
  305.   'Ensure a repaint if window was made smaller
  306.     If Me.Width < LastWidth Or Me.Height < LastHeight Then
  307.       MDIForm_Paint
  308.     End If
  309.   
  310.   'Store new size
  311.     LastState = WindowState
  312.     LastWidth = Me.Width
  313.     LastHeight = Me.Height
  314.  
  315. End Sub
  316.  
  317. Sub MDIForm_Unload (Cancel As Integer)
  318.  
  319.   Dim i%
  320.   For i = Forms.Count - 1 To 0 Step -1
  321.     If Forms(i) Is Me Then
  322.       'do nothing
  323.     Else
  324.       Unload Forms(i)
  325.     End If
  326.   Next i
  327.  
  328. End Sub
  329.  
  330. Sub MsgBlaster1_Message (MsgVal As Integer, wParam As Integer, lParam As Long, ReturnVal As Long)
  331.   
  332.   'The heart and soul of the whole enchilada!
  333.   '(sorry about the mixed metaphor<g>)
  334.   Select Case MsgVal
  335.     Case WM_PAINT
  336.       MDIForm_Paint
  337.     Case WM_ERASEBKGND
  338.       'Eat it!
  339.   End Select
  340.  
  341. End Sub
  342.  
  343. Sub mTest_Click ()
  344.   Unload Me
  345. End Sub
  346.  
  347. Sub Panel3D1_MouseMove (Button As Integer, Shift As Integer, X As Single, Y As Single)
  348.   'Update status bar
  349.     DisplayStatus ""
  350. End Sub
  351.  
  352.